﻿@using Newtouch.Infrastructure;
@{
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style>
    #leftPart {
        float: left;
        width: 24%;
    }

        #leftPart .btn-group {
            float: right;
            font-size: 12px;
            font-weight: 200;
        }

    #rightPart {
        float: left;
        width: 75%;
        padding-left: 7px;
    }
</style>

<div id="leftPart" class="rows">
    <div class="gridPanel">
        <table id="gridList"></table>
    </div>
</div>
<div id="rightPart" class="rows">
    <div class="gridPanel">
        <table id="gridRightList"></table>
    </div>
    @Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel()
{
    ShowKeyList = new[] { 2,3,4},
    F2Text = "新增",
    F3Text = "修改",
    F4Text = "删除",
})
</div>
    <script>

    $(function () {
        gridList();
        gridRightList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            treeGrid: true,
            treeGridModel: "adjacency",
            ExpandColumn: "Blzt",
            url: "/SysItem/GetQcBllxMbTree",
            postData: { keyword: "" },
            height: $(window).height() - 80,
            width: $(".dv-left").width(),
            colModel: [
                { label: "Id", name: "Id", hidden: true, key: true },
                { label: "质控项目", name: "bllxmc", width: 155, align: 'left' },
                { label: "质控代码", name: "bllx", width: 60, align: 'left' },
                { label: "ly", name: "ly", width: 60, align: 'left', hidden: true, },
            ],
            onSelectRow: function (rowid, status) {
                var rowData = $("#gridList").jqGrid('getRowData', rowid);
                $("#gridRightList").jqGrid('setGridParam', {
                    postData: { keyword: rowData.bllx },
                    page: 1,
                }).trigger('reloadGrid');

            }
        });

    }
    function gridRightList() {
        var $gridrightList = $("#gridRightList");
        $gridrightList.dataGrid({
            caption: "质控明细项",
            url: "/SysItem/GetZkxmList",
            postData: { keyword: "" },
            rownumbers: false,
            height: $(window).height() - 123,
            colModel: [
                { label: "Id", name: "Id", hidden: true, key: true },
                { label: "BlmbId", name: "BlmbId", hidden: true, },
                { label: "zklx", name: "zklx", hidden: true, },
                { label: "质控项目", name: "Bllmbmc", width: 100, align: "center", },
                { label: "质控编码", name: "Code", width: 100, align: "center", },
                { label: "质控名称", name: "Name", width: 200, align: "center",},
                { label: "质控评分", name: "Score", width: 95, align: "center", },
                { label: "评分说明", name: "Remark", width: 165, align: "left" },
                { label: "显示顺序", name: "Px", width: 80, align: "left" },
            ],
            unwritten: false,
            viewrecords: true,
           
        });
    }
    function newtouch_event_f2() {
        var seleRow = $("#gridList").jqGridRowValue();
        if (!!!seleRow.bllx) {
            $.modalAlert("请选中一条质控项目", "error");
            return;
        }
        $.modalOpen({
            id: "Form",
            title: "新增质控项",
            url: "/QualityControlManage/SysItem/Form?" + "bllx=" + seleRow.bllx + "&bllxmc=" + seleRow.bllxmc + "&Type=" + seleRow.ly + "&czlx=" + "insert",
            width: "640px",
            height: "350px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function newtouch_event_f3()
    {
        btn_edit();
    }
    function btn_edit() {
        var seleRow = $("#gridRightList").jqGridRowValue();
        if (!!!seleRow.BlmbId) {
            $.modalAlert("请选中一条质控明细", "error");
            return;
        }
        $.modalOpen({
            id: "Form",
            title: "修改质控项",
            url: "/QualityControlManage/SysItem/Form?" + "Id=" + seleRow.Id + "&czlx=" + "update",
            width: "640px",
            height: "350px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function newtouch_event_f4() {
        var seleRow = $("#gridRightList").jqGridRowValue();
        if (!!!seleRow.Id) {
            $.modalAlert("请选中一条要删除的质控明细", "error");
            return;
        }
        $.modalConfirm("是否删除"+seleRow.Name, function (flag) {
            if (flag) {
                $.najax({
                    url: "/QualityControlManage/SysItem/ZkDetailDel",
                    data: { Id: seleRow.Id },
                    dataType: "json",
                    success: function (res) {
                        $.modalAlert("删除成功", 'warning');
                        $("#gridRightList").jqGrid('setGridParam', {
                            postData: { keyword: seleRow.BlmbId },
                        }).trigger('reloadGrid');
                    }
                });

            } else {
                return false;
            }
        });
    }
    </script>
